'''
Created on Feb 27, 2011

@author: Roni
'''
import time

class TimerManager(object):
    ''' A class for timing parts of the code, mainly for profiling '''  
    def __init__(self):
        self.timers = dict()
        
    def create_timer(self,timer_name):
        self.timers[timer_name]=Timer()
    def start(self,timer_name):
        self.timers[timer_name].start()
    def stop(self,timer_name):
        self.timers[timer_name].stop();
    def get_total_time(self,timer_name):
        return self.timers[timer_name].elapsed_time
    

class Timer(object):
    ''' A single timer object '''
    def __init__(self):
        self.started = False    
    def start(self):
        self.started = True
        self.start_time= time.clock()
    def stop(self):
        self.started = False
        self.elapsed_time = time.clock()-self.start_time
    
    
    
